//npm install -g gulp-clean-css gulp-concat gulp-uglify gulp-rename gulp-rename gulp-minify-css gulp-rev
var gulp = require('gulp'),
    cleanCSS = require('gulp-clean-css'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    rename = require('gulp-rename');
var minifyCss = require('gulp-minify-css');
var rev = require('gulp-rev');
var zip = require('gulp-zip');

var config = require("./config.json");

var version = config.version;
var destPath = config.destPath;

var defaultTask = [];




//css处理
for (key in config.gulp_css) {
    gulp.task(key, function() {
        gulp.src(config.gulp_css[key])
            .pipe(cleanCSS())
            .pipe(minifyCss()) //- 压缩处理成一行
            .pipe(concat(version + '/' + key + '.css'))
            .pipe(gulp.dest(destPath))
    });
    defaultTask.push(key);
}

//自动压缩
gulp.task('zip_all', function() {
    gulp.src("./dist/1.0.0/**")
        .pipe(zip(version + '_' + new Date().getTime() + '.zip'))
        .pipe(gulp.dest('./dist/'))
});


// var page_list_css_config = [
//     staticPath + 'css/base.css',
//     staticPath + 'css/card.css',
//     staticPath + 'css/list.css'
// ];

// gulp.task('page_list_css', function() {

//     gulp.src(page_list_css_config)
//         .pipe(cleanCSS())
//         .pipe(minifyCss()) //- 压缩处理成一行
//         .pipe(concat(version + '/page_list.css'))
//         .pipe(gulp.dest('./dist/'))
// });

// defaultTask.push("page_list_css");



gulp.task('default', defaultTask, function() {});